package com.oracle.service;

import com.oracle.mapper.UserMapper;
import com.oracle.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
你好
 */
import java.util.List;
@Service("userService")
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public List<User> getAllUsers(String keyName,int rid) {
        return userMapper.selectAllUsers(keyName,rid);
    }

    @Override
    public User login(String userCode, String userPassword) {
        return userMapper.selectUserByUserCodeAndUserPassword(userCode,userPassword);
    }

    @Override
    public boolean addUser(User user) {
        return  userMapper.insertUser(user)>0;
    }

    @Override
    public int findUserCountByUserCode(String userCode) {
        return userMapper.selectUserCountByUserCode(userCode);
    }

    @Override
    public User findUserById(int id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public boolean updateUser(User user) {
        return userMapper.updateUser(user)>0;
    }

    @Override
    public boolean deleteUserById(int id) {
        return userMapper.deleteUserById(id)>0;
    }


}
